 function encipher(num_rounds, v, k) {

    var v0 = v[0];
    var v1 = v[1];
    var sum = 0, delta = 0x9E3779B9;
    for (var i = 0; i < num_rounds; i++) {

      v0 += (((v1 << 4) ^ (v1 >>> 5)) + v1) ^ (sum + k[sum & 3]);
      sum += delta;
      v1 += (((v0 << 4) ^ (v0 >>> 5)) + v0) ^ (sum + k[(sum >>> 11) & 3]);

    }
    v[0] = v0;
    v[1] = v1;

  };

function decipher(num_rounds, v, k) {

    var v0 = v[0];
    var v1 = v[1];
    var delta = 0x9E3779B9, sum = delta * num_rounds;
    for (var i = 0; i < num_rounds; i++) {

      v1 -= ((v0 << 4 ^ v0 >>> 5) + v0) ^ (sum + k[sum >>> 11 & 3]);
      sum -= delta;
      v0 -= ((v1 << 4 ^ v1 >>> 5) + v1) ^ (sum + k[sum & 3]);

    }
    v[0] = v0;
    v[1] = v1;

  };

 function encrypt(v, k) {

    return this.encryptString(64, v, k);

  };

  function decrypt (v, k) {

    return this.decryptString(64, v, k);

  };

module.exports = {
  xTEAEncryptWithKey: encipher,
  xTEADecryptWithKey: decipher
}

